include_directories(${ANTLR4_INCLUDE_DIRS})
include_directories(${ANTLR_MYToy_OUTPUT_DIR})

# 获得默认的mlir方言库和转换库
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
# 设置要链接的库
set(LIBS
        ${dialect_libs}
        ${conversion_libs}
        MLIRArithDialect
        MLIROptLib
        MLIRtoy
        )

# 添加可执行文件
add_llvm_executable(toy-opt toy-opt.cpp)
# 更新编译参数
llvm_update_compile_flags(toy-opt)
# 设置链接库
target_link_libraries(toy-opt 
        PRIVATE 
        ${LIBS}
        Threads::Threads
        parser
        lower_to_arith
        lower_to_llvm
        antlr4_static
        )
# 检查
mlir_check_all_link_libraries(toy-opt)